package cz.muni.fi.pa165.library.backend;

import cz.muni.fi.pa165.library.api.Genre;
import java.util.List;

/**
 * This service allows to implement simple CRUD function and fuction for
 * retreaving data from database of DAO entity book.
 *
 *
 * @author Zuzana Foltýnová
 */
public interface BookDAO {

    /**
     * Stores new book into database. Id for the new book is automatically
     * generated and stored into id attribute. Book is set to be AVAILABLE.
     *
     * @param book book entity to be created.
     * @return created book with new id.
     * @throws IllegalArgumentException when book is null or books parameters
     * are not correct.
     */
    public Book createBook(Book book) throws IllegalArgumentException;

    /**
     * Returns list of all books in the database.
     *
     * @return list of all books in the database.
     */
    public List<Book> findAllBooks();

    public List<Book> findAllAvailableBooks();

    /**
     * Returns book with given id.
     *
     * @param id primary key of requested book.
     * @return book with given id or null if such book does not exist.
     * @throws IllegalArgumentException when book id is not correct.
     */
    public Book findBookById(Long id) throws IllegalArgumentException;

    /**
     * Returns list of books with given author.
     *
     * @param author author of requested book.
     * @return list of books with given author.
     * @throws IllegalArgumentException when author is null or empty.
     */
    public List<Book> findBookByAuthor(String author) throws IllegalArgumentException;

    /**
     * Returns list of books with given title.
     *
     * @param title title of requested book.
     * @return list of books with given title.
     * @throws IllegalArgumentException when book title is null or empty.
     */
    public List<Book> findBookByTitle(String title) throws IllegalArgumentException;

    /**
     * Returns list of books with given genre.
     *
     * @param genre of requested book.
     * @return list of books with given genre.
     * @throws IllegalArgumentException when genre is null or is not in correct
     * form.
     */
    public List<Book> findBookByGenre(Genre genre) throws IllegalArgumentException;

    /**
     * Returns book with given ISBN.
     *
     * @param isbn isbn of publication of requested book.
     * @return list of books with given isbn.
     * @throws IllegalArgumentException when book ISBN is null or is not
     * correct.
     */
    public List<Book> findBookByIsbn(String ISBN) throws IllegalArgumentException;

    /**
     * Updates book in database.
     *
     * @param book updated book to be stored into database.
     * @throws IllegalArgumentException when book is null or books parameters
     * are not correct.
     */
    public void updateBook(Book book) throws IllegalArgumentException;

    /**
     * Deletes book from database.
     *
     * @param book book to be deleted from database.
     * @throws IllegalArgumentException when book is null or books parameters
     * are not correct.
     */
    public void deleteBook(Book book) throws IllegalArgumentException;
}
